﻿using System;
using System.Drawing;
using Pharmacy.Data;
using Pharmacy.Entities;

public partial class ChangePassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var httpCookie = Request.Cookies["LoginUser"];
            lbl_Username.Text = httpCookie.Value;
        }
    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        WebUser user = DataRepository.WebUserProvider.GetByUserId(lbl_Username.Text);
        if (user.Password==tb_OldPassword.Text)
        {
            user.Password = tb_NewPassword.Text;
            DataRepository.WebUserProvider.Update(user);
            lbl_Notice.Text = "Password update success";
            lbl_Notice.ForeColor = Color.Green;
            
        }
        else
        {
            lbl_Notice.Text = "Wrong old password";
            lbl_Notice.ForeColor = Color.Red;
        }
    }
}
